<template>
<el-container>
    <el-aside width="200px">
       <MemberMenu></MemberMenu>
    </el-aside>

<div class="formCss">
  <button class="taskCss" @click="departmentTask">部门任务</button> <button @click="enterpriseTask" class="taskCss">企业任务</button>
  <el-divider style="height:2px;background-color:gray;width:650px" />
  <el-table :data="tasks" highlight-current-row @current-change="handleCurrentChange" style="width: 100%">
    <el-table-column label="序号" type="index" width="50"></el-table-column>
    <el-table-column prop="department.name" label="所在部门" width="120"></el-table-column>
    <el-table-column prop="project.name" label="项目名称" width="120"></el-table-column>
    <el-table-column prop="name" label="任务名称" width="120"></el-table-column>
    <el-table-column prop="details" label="任务详情" width="120"></el-table-column>
    <el-table-column prop="subTime"  label="任务发布的时间"  width="120"></el-table-column>
  </el-table>
</div>
  
</el-container>
</template>

<script>
import MemberMenu from '@/components/menu/MemberMenu.vue'
import instance from '@/utlis/request.js'


export default {
    
    components: {
        MemberMenu,
        
    },
  
    data() {
        
        return {
        tasks:[],
        };
    },
    //钩子函数   一般用来初始化数据
    created:function(){
      this.initData();
    },
     methods: {
      //显示页面所有的任务功能
      initData(){
        var companyUser=window.sessionStorage.getItem("companyUserId");
        //console.log("====================")
        //console.log(companyUser);
        //console.log("====================")
        var companyUserObj = JSON.parse(companyUser);
        //console.log(companyUserObj);
        instance.get("task/member/list/"+companyUserObj).then(res=>{
          this.tasks=res.data.data;
        })
      },
      //部门任务
      departmentTask(){
        var companyUser=window.sessionStorage.getItem("companyUserId");
        var companyUserObj = JSON.parse(companyUser);   
        instance.get("task/member/list/"+companyUserObj).then(res=>{
          this.tasks=res.data.data;
        })
      },
      //企业任务
      enterpriseTask(){
        var companyUser=window.sessionStorage.getItem("companyUserId");
        var companyUserObj = JSON.parse(companyUser);   
        instance.get("task/member/enterpriseTask/"+companyUserObj).then(res=>{
          this.tasks=res.data.data;
        })
      }

    }

}
</script>
<style scoped>
  
    
    .formCss{
         width: 900px;
         margin-left: 320px;
    }
   .taskCss{
     margin-top:30px;
   }

   
</style>